using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace DTO
{
	/// <summary> 
	///Author: daiduong19051986@gmail.com 
	/// <summary>
	
    public class TVC_MVPDETInfo
    {
		#region Local Variable
		public enum Field
		{
			AUTO_ID,
			Code,
			FieldName,
			SourceName,
			START,
			LENGTH,
			OPERATOR,
			VALUEF,
			VALUET
		}
		private Int32 _AUTO_ID;
		private String _Code;
		private String _FieldName;
		private String _SourceName;
		private Int32 _START;
		private Int32 _LENGTH;
		private String _OPERATOR;
		private String _VALUEF;
		private String _VALUET;
		
		public Int32 AUTO_ID{	get{ return _AUTO_ID;} set{_AUTO_ID = value;} }
		public String Code{	get{ return _Code;} set{_Code = value;} }
		public String FieldName{	get{ return _FieldName;} set{_FieldName = value;} }
		public String SourceName{	get{ return _SourceName;} set{_SourceName = value;} }
		public Int32 START{	get{ return _START;} set{_START = value;} }
		public Int32 LENGTH{	get{ return _LENGTH;} set{_LENGTH = value;} }
		public String OPERATOR{	get{ return _OPERATOR;} set{_OPERATOR = value;} }
		public String VALUEF{	get{ return _VALUEF;} set{_VALUEF = value;} }
		public String VALUET{	get{ return _VALUET;} set{_VALUET = value;} }
		
        #endregion LocalVariable
        
        #region Constructor
		public TVC_MVPDETInfo()
		{
			_AUTO_ID = 0;
			_Code = "";
			_FieldName = "";
			_SourceName = "";
			_START = 0;
			_LENGTH = 0;
			_OPERATOR = "";
			_VALUEF = "";
			_VALUET = "";
		}
		public TVC_MVPDETInfo(
		Int32 AUTO_ID,
		String Code,
		String FieldName,
		String SourceName,
		Int32 START,
		Int32 LENGTH,
		String OPERATOR,
		String VALUEF,
		String VALUET
		)
		{
			_AUTO_ID = AUTO_ID;
			_Code = Code;
			_FieldName = FieldName;
			_SourceName = SourceName;
			_START = START;
			_LENGTH = LENGTH;
			_OPERATOR = OPERATOR;
			_VALUEF = VALUEF;
			_VALUET = VALUET;
		}
		public TVC_MVPDETInfo(DataRow dr)
		{
			if (dr != null)
			{
				_AUTO_ID = dr[Field.AUTO_ID.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.AUTO_ID.ToString()]);
				_Code = dr[Field.Code.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Code.ToString()]);
				_FieldName = dr[Field.FieldName.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.FieldName.ToString()]);
				_SourceName = dr[Field.SourceName.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.SourceName.ToString()]);
				_START = dr[Field.START.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.START.ToString()]);
				_LENGTH = dr[Field.LENGTH.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.LENGTH.ToString()]);
				_OPERATOR = dr[Field.OPERATOR.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.OPERATOR.ToString()]);
				_VALUEF = dr[Field.VALUEF.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.VALUEF.ToString()]);
				_VALUET = dr[Field.VALUET.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.VALUET.ToString()]);
			}
		}
		public TVC_MVPDETInfo(DataRowView dr)
		{
			if (dr != null)
			{
				_AUTO_ID = dr[Field.AUTO_ID.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.AUTO_ID.ToString()]);
				_Code = dr[Field.Code.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Code.ToString()]);
				_FieldName = dr[Field.FieldName.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.FieldName.ToString()]);
				_SourceName = dr[Field.SourceName.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.SourceName.ToString()]);
				_START = dr[Field.START.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.START.ToString()]);
				_LENGTH = dr[Field.LENGTH.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.LENGTH.ToString()]);
				_OPERATOR = dr[Field.OPERATOR.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.OPERATOR.ToString()]);
				_VALUEF = dr[Field.VALUEF.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.VALUEF.ToString()]);
				_VALUET = dr[Field.VALUET.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.VALUET.ToString()]);
			}
		}
		public TVC_MVPDETInfo(TVC_MVPDETInfo objEntr)
		{			
			_AUTO_ID = objEntr.AUTO_ID;			
			_Code = objEntr.Code;			
			_FieldName = objEntr.FieldName;			
			_SourceName = objEntr.SourceName;			
			_START = objEntr.START;			
			_LENGTH = objEntr.LENGTH;			
			_OPERATOR = objEntr.OPERATOR;			
			_VALUEF = objEntr.VALUEF;			
			_VALUET = objEntr.VALUET;			
		}
        #endregion Constructor
        
        #region InitTable
		public DataTable ToDataTable()
		{
			DataTable dt = new DataTable("TVC_MVPDETHVJ");
			dt.Columns.AddRange(new DataColumn[] { 
				new DataColumn(Field.AUTO_ID.ToString(), typeof(Int32)),
				new DataColumn(Field.Code.ToString(), typeof(String)),
				new DataColumn(Field.FieldName.ToString(), typeof(String)),
				new DataColumn(Field.SourceName.ToString(), typeof(String)),
				new DataColumn(Field.START.ToString(), typeof(Int32)),
				new DataColumn(Field.LENGTH.ToString(), typeof(Int32)),
				new DataColumn(Field.OPERATOR.ToString(), typeof(String)),
				new DataColumn(Field.VALUEF.ToString(), typeof(String)),
				new DataColumn(Field.VALUET.ToString(), typeof(String))
			});
			return dt;
		}
		public DataRow ToDataRow(DataTable dt)
		{
			DataRow row = dt.NewRow();
			row[Field.AUTO_ID.ToString()] = _AUTO_ID;
			row[Field.Code.ToString()] = _Code;
			row[Field.FieldName.ToString()] = _FieldName;
			row[Field.SourceName.ToString()] = _SourceName;
			row[Field.START.ToString()] = _START;
			row[Field.LENGTH.ToString()] = _LENGTH;
			row[Field.OPERATOR.ToString()] = _OPERATOR;
			row[Field.VALUEF.ToString()] = _VALUEF;
			row[Field.VALUET.ToString()] = _VALUET;
			return row;
		}
        #endregion InitTable
    }
}
